﻿namespace GarminConnect
{
    /// <summary>
    /// Garmin 区域枚举
    /// </summary>
    public enum GarminDomain
    {
        //中国区
        GarminCN,
        //国际区
        GarminCom
    }

    /// <summary>
    /// 导出文件类型枚举
    /// </summary>
    public enum ExportFileType
    {
        tcx,
        gpx,
        kml,
        zip
    }

    /// <summary>
    /// 上传文件类型枚举
    /// </summary>
    public enum UploadFileType
    {
        tcx,
        gpx,
        fit
    }

    /// <summary>
    /// 用户信息
    /// </summary>
    public class UserInfo
    {
        public int UserProfileId { get; set; }
        public string? Username { get; set; }
        public string? EmailAddress { get; set; }
        public string? Locale { get; set; }
        public string? MeasurementSystemKey { get; set; }
        public string? TimeFormatKey { get; set; }
        public string? DateFormatKey { get; set; }
        public string? NumberFormatKey { get; set; }
        public string? HeartRateDisplayFormatKey { get; set; }
        public string? PowerDisplayFormatKey { get; set; }
        public string? TimeZoneGroupKey { get; set; }
        public string? DayKey { get; set; }  
        public bool IsPublicByDefault { get; set; }
        public List<string>? Roles { get; set; }
        public string? DisplayName { get; set; }
        public string? TocAcceptedDate { get; set; }
        public string? DefaultActivityPrivacy { get; set; }
        public string? CustomerId { get; set; }
        public string? Birthdate { get; set; }
        public string? SocialNetwork { get; set; }
        public string? SocialIcon { get; set; }
        public bool SystemUser { get; set; }
        public bool SystemMetricUser { get; set; }
        public bool UnderAge { get; set; }
    }

    /// <summary>
    /// 社交资料
    /// </summary>
    public class SocialProfile
    {
        public int Id { get; set; }
        public int ProfileId { get; set; }
        public string? GarminGUID { get; set; }
        public string? DisplayName { get; set; }
        public string? FullName { get; set; }
        public string? UserName { get; set; }
        public string? ProfileImageUuid { get; set; }
        public string? ProfileImageUrlLarge { get; set; }
        public string? ProfileImageUrlMedium { get; set; }
        public string? ProfileImageUrlSmall { get; set; }
        public string? Location { get; set; }
        public string? FacebookUrl { get; set; }
        public string? TwitterUrl { get; set; }
        public string? PersonalWebsite { get; set; }
        public string? Motivation { get; set; }
        public string? Bio { get; set; }
        public string? PrimaryActivity { get; set; }
        public List<string>? FavoriteActivityTypes { get; set; }
        public double RunningTrainingSpeed { get; set; }
        public double CyclingTrainingSpeed { get; set; }
        public List<string>? FavoriteCyclingActivityTypes { get; set; }
        public string? CyclingClassification { get; set; }
        public double CyclingMaxAvgPower { get; set; }
        public double SwimmingTrainingSpeed { get; set; }
        public string? ProfileVisibility { get; set; }
        public string? ActivityStartVisibility { get; set; }
        public string? ActivityMapVisibility { get; set; }
        public string? CourseVisibility { get; set; }
        public string? ActivityHeartRateVisibility { get; set; }
        public string? ActivityPowerVisibility { get; set; }
        public string? BadgeVisibility { get; set; }
        public bool ShowAge { get; set; }
        public bool ShowWeight { get; set; }
        public bool ShowHeight { get; set; }
        public bool ShowWeightClass { get; set; }
        public bool ShowAgeRange { get; set; }
        public bool ShowGender { get; set; }
        public bool ShowActivityClass { get; set; }
        public bool ShowVO2Max { get; set; }
        public bool ShowPersonalRecords { get; set; }
        public bool ShowLast12Months { get; set; }
        public bool ShowLifetimeTotals { get; set; }
        public bool ShowUpcomingEvents { get; set; }
        public bool ShowRecentFavorites { get; set; }
        public bool ShowRecentDevice { get; set; }
        public bool ShowRecentGear { get; set; }
        public bool ShowBadges { get; set; }
        public string? OtherActivity { get; set; }
        public string? OtherPrimaryActivity { get; set; }
        public string? OtherMotivation { get; set; }
        public List<string>? UserRoles { get; set; }
        public bool NameApproved { get; set; }
        public string? UserProfileFullName { get; set; }
        public bool MakeGolfScorecardsPrivate { get; set; }
        public bool AllowGolfLiveScoring { get; set; }
        public bool AllowGolfScoringByConnections { get; set; }
        public int UserLevel { get; set; }
        public int UserPoint { get; set; }
        public string? LevelUpdateDate { get; set; }
        public bool LevelIsViewed { get; set; }
        public int LevelPointThreshold { get; set; }
        public int UserPointOffset { get; set; }
        public bool UserPro { get; set; }
    }

    /// <summary>
    /// 社交连接
    /// </summary>
    public class SocialConnection
    {
        public int UserId { get; set; }

        public string? DisplayName { get; set; }

        public string? FullName { get; set; }

        public string? Location { get; set; }

        public string? ProfileImageUrlMedium { get; set; }

        public string? ProfileImageUrlSmall { get; set; }

        public int UserLevel { get; set; }

        public int ConnectionRequestId { get; set; }

        public int ConnectionRequestorId { get; set; }

        public int UserConnectionStatus { get; set; }

        public List<string>? UserRoles { get; set; }

        public int ProfileVisibility { get; set; }

        public List<string>? DeviceInvitations { get; set; }

        public bool NameApproved { get; set; }

        public int BadgeVisibility { get; set; }

        public bool UserPro { get; set; }
    }

    /// <summary>
    /// 社交连接列表
    /// </summary>
    public class SocialConnections
    {
        public string? FullName { get; set; }
        public List<SocialConnection>? UserConnections { get; set; }
        public string? Pagination { get; set; }
    }

    /// <summary>
    /// 社交连接徽章
    /// </summary>
    public class BadgeSocialConnection
    {
        public string? UserProfileId { get; set; }
        public string? Pagination { get; set; }
        public string? DisplayName { get; set; }
        public string? ProfileImageUrlMedium { get; set; }
        public string? ProfileImageUrlSmall { get; set; }
        public int UserLevel { get; set; }
        public string? BadgeEarnedDate { get; set; }
    }

    /// <summary>
    /// 徽章相关信息
    /// </summary>
    public class BadgeRelated
    {
        public string? BadgeId { get; set; }
        public string? BadgeKey { get; set; }
        public string? BadgeName { get; set; }
        public string? BadgeUuid { get; set; }
        public int BadgeCategoryId { get; set; }
        public int BadgeDifficultyId { get; set; }
        public int BadgePoints { get; set; }
        public List<int> BadgeTypeIds { get; set; } = [];
        public bool EarnedByMe { get; set; }
    }

    /// <summary>
    /// 徽章
    /// </summary>
    public class Badge
    {
        public string? BadgeId { get; set; }
        public string? BadgeKey { get; set; }
        public string? BadgeName { get; set; }
        public string? BadgeUuid { get; set; }
        public int BadgeCategoryId { get; set; }
        public int BadgeDifficultyId { get; set; }
        public int BadgePoints { get; set; }
        public List<int> BadgeTypeIds { get; set; } = [];
        public string? BadgeSeriesId { get; set; }
        public string? BadgeStartDate { get; set; }
        public string? BadgeEndDate { get; set; }
        public int UserProfileId { get; set; }
        public string? FullName { get; set; }
        public string? DisplayName { get; set; }
        public string? BadgeEarnedDate { get; set; }
        public int BadgeEarnedNumber { get; set; }
        public string? BadgeLimitCount { get; set; }
        public bool BadgeIsViewed { get; set; }
        public int BadgeProgressValue { get; set; }
        public string? BadgeTargetValue { get; set; }
        public string? BadgeUnitId { get; set; }
        public int BadgeAssocTypeId { get; set; }
        public string? BadgeAssocDataId { get; set; }
        public string? BadgeAssocDataName { get; set; }
        public bool EarnedByMe { get; set; }
        public string? CurrentPlayerType { get; set; }
        public string? UserJoined { get; set; }
        public string? BadgeChallengeStatusId { get; set; }
        public string? BadgePromotionCodeType { get; set; }
        public string? PromotionCodeStatus { get; set; }
        public string? CreateDate { get; set; }
        public List<BadgeRelated>? RelatedBadges { get; set; }
        public int ConnectionNumber { get; set; }
        public List<BadgeSocialConnection>? Connections { get; set; }
    }

    /// <summary>
    /// 装备信息
    /// </summary>
    public class Gear
    {
        public int GearPk { get; set; }
        public string? Uuid { get; set; }
        public int UserProfilePk { get; set; }
        public string? GearMakeName { get; set; }
        public string? GearModelName { get; set; }
        public string? GearTypeName { get; set; }
        public string? GearStatusName { get; set; }
        public string? DisplayName { get; set; }
        public string? CustomMakeModel { get; set; }
        public string? ImageNameLarge { get; set; }
        public string? ImageNameMedium { get; set; }
        public string? ImageNameSmall { get; set; }
        public string? DateBegin { get; set; }
        public string? DateEnd { get; set; }
        public int MaximumMeters { get; set; }
        public bool Notified { get; set; }
        public string? CreateDate { get; set; }
        public string? UpdateDate { get; set; }
    }

    /// <summary>
    /// 用户授权1
    /// </summary>
    public class Oauth1Consumer
    {
        public string? Key { get; set; }
        public string? Secret { get; set; }
    }

    /// <summary>
    /// 用户授权1信息
    /// </summary>
    public class Oauth1
    {
        public Oauth1Token? Token { get; set; }
        public OAuth1Client? Oauth { get; set; }  // 这里 OAuth 类型需要你定义或替换
    }

    /// <summary>
    /// 佳明Tokens
    /// </summary>
    public class GarminTokens
    {
        public Oauth1Token? Oauth1 { get; set; }
        public Oauth2Token? Oauth2 { get; set; }
    }

    /// <summary>
    /// OAuth1 Token 信息
    /// </summary>
    public class Oauth1Token
    {
        public string? OauthToken { get; set; }
        public string? OauthTokenSecret { get; set; }
    }

    /// <summary>
    /// OAuth2 Token 信息
    /// </summary>
    public class Oauth2Token
    {
        public string? Scope { get; set; }
        public string? Jti { get; set; }
        public string? AccessToken { get; set; }
        public string? TokenType { get; set; }
        public string? RefreshToken { get; set; }
        public long ExpiresIn { get; set; }
        public long RefreshTokenExpiresIn { get; set; }
        public long ExpiresAt { get; set; }
        public long RefreshTokenExpiresAt { get; set; }
        public string? LastUpdateDate { get; set; }
        public string? ExpiresDate { get; set; }
    }

    /// <summary>
    /// 用户设置
    /// </summary>
    public class UserSettings
    {
        public int Id { get; set; }

        public UserData UserData { get; set; } = null!;

        public UserSleep UserSleep { get; set; } = null!;

        public string? ConnectDate { get; set; }

        public string? SourceType { get; set; }

        public List<UserSleepWindows> UserSleepWindows { get; set; } = [];
    }

    /// <summary>
    /// 用户睡眠
    /// </summary>
    public class UserSleep
    {
        public int SleepTime { get; set; }
        public bool DefaultSleepTime { get; set; }
        public int WakeTime { get; set; }
        public bool DefaultWakeTime { get; set; }
    }

    /// <summary>
    /// 用户数据
    /// </summary>
    public class UserData
    {
        public string? Gender { get; set; }
        public string? Weight { get; set; }
        public string? Height { get; set; }
        public string? TimeFormat { get; set; }
        public string? BirthDate { get; set; }
        public string? MeasurementSystem { get; set; }
        public string? ActivityLevel { get; set; }
        public string? Handedness { get; set; }
        public PowerFormat? PowerFormat { get; set; }
        public HeartRateFormat? HeartRateFormat { get; set; }
        public FirstDayOfWeek? FirstDayOfWeek { get; set; }
        public string? Vo2MaxRunning { get; set; }
        public string? Vo2MaxCycling { get; set; }
        public string? LactateThresholdSpeed { get; set; }
        public string? LactateThresholdHeartRate { get; set; }
        public string? DiveNumber { get; set; }
        public string? IntensityMinutesCalcMethod { get; set; }
        public int ModerateIntensityMinutesHrZone { get; set; }
        public int VigorousIntensityMinutesHrZone { get; set; }
        public string? HydrationMeasurementUnit { get; set; }
        public List<string> HydrationContainers { get; set; } = [];
        public bool HydrationAutoGoalEnabled { get; set; }
        public string? FirstbeatMaxStressScore { get; set; }
        public string? FirstbeatCyclingLtTimestamp { get; set; }
        public string? FirstbeatRunningLtTimestamp { get; set; }
        public string? ThresholdHeartRateAutoDetected { get; set; }
        public string? FtpAutoDetected { get; set; }
        public string? TrainingStatusPausedDate { get; set; }
        public WeatherLocation? WeatherLocation { get; set; }
        public string? GolfDistanceUnit { get; set; }
        public string? GolfElevationUnit { get; set; }
        public string? GolfSpeedUnit { get; set; }
        public string? ExternalBottomTime { get; set; }
    }

    /// <summary>
    /// 电池格式
    /// </summary>
    public class PowerFormat
    {
        public int FormatId { get; set; }
        public string? FormatKey { get; set; }
        public int MinFraction { get; set; }
        public int MaxFraction { get; set; }
        public bool GroupingUsed { get; set; }
        public string? DisplayFormat { get; set; }
    }

    /// <summary>
    /// 心率格式
    /// </summary>
    public class HeartRateFormat
    {
        public int FormatId { get; set; }
        public string? FormatKey { get; set; }
        public int MinFraction { get; set; }
        public int MaxFraction { get; set; }
        public bool GroupingUsed { get; set; }
        public string? DisplayFormat { get; set; }
    }

    /// <summary>
    /// 一周的第一天
    /// </summary>
    public class FirstDayOfWeek
    {
        public int DayId { get; set; }
        public string? DayName { get; set; }
        public int SortOrder { get; set; }
        public bool IsPossibleFirstDay { get; set; }
    }

    /// <summary>
    /// 天气位置信息
    /// </summary>
    public class WeatherLocation
    {
        public string? UseFixedLocation { get; set; }
        public string? Latitude { get; set; }
        public string? Longitude { get; set; }
        public string? LocationName { get; set; }
        public string? IsoCountryCode { get; set; }
        public string? PostalCode { get; set; }
    }

    /// <summary>
    /// 用户睡眠时间段
    /// </summary>
    public class UserSleepWindows
    {
        public string? SleepWindowFrequency { get; set; }
        public int StartSleepTimeSecondsFromMidnight { get; set; }
        public int EndSleepTimeSecondsFromMidnight { get; set; }
    }

    /// <summary>
    /// 活动统计总数
    /// </summary>
    public class CountActivities
    {
        public int CountOfActivities { get; set; }
        public string? Date { get; set; }
        public Stats? Stats { get; set; }
    }

    /// <summary>
    /// 统计信息
    /// </summary>
    public class Stats
    {
        public Dictionary<string, string>? All { get; set; }
    }

    ///////////////////// Workouts
    
    /// <summary>
    /// 锻炼
    /// </summary>
    public class Workout
    {
        public int? WorkoutId { get; set; }
        public int? OwnerId { get; set; }
        public string WorkoutName { get; set; } = null!;
        public string? Description { get; set; }
        public DateTime UpdateDate { get; set; }
        public DateTime CreatedDate { get; set; }
        public ISportType SportType { get; set; } = null!;
        public string? TrainingPlanId { get; set; } 
        public Author Author { get; set; } = null!;
        public int EstimatedDurationInSecs { get; set; }
        public string? EstimatedDistanceInMeters { get; set; }  
        public string? EstimateType { get; set; } 
        public Unit EstimatedDistanceUnit { get; set; } = null!;
        public int PoolLength { get; set; }
        public Unit PoolLengthUnit { get; set; } = null!;
        public string WorkoutProvider { get; set; } = null!;
        public string WorkoutSourceId { get; set; } = null!;
        public string? Consumer { get; set; }  
        public string? AtpPlanId { get; set; } 
        public string? WorkoutNameI18nKey { get; set; } 
        public string? DescriptionI18nKey { get; set; } 
        public bool Shared { get; set; }
        public bool Estimated { get; set; }
    }

    /// <summary>
    /// 锻炼详情
    /// </summary>
    public class WorkoutDetail : Workout
    {
        public List<WorkoutSegment> WorkoutSegments { get; set; } = [];
    }

    /// <summary>
    /// 作者
    /// </summary>
    public class Author
    {
        public string? UserProfilePk { get; set; }
        public string? DisplayName { get; set; }
        public string? FullName { get; set; }
        public string? ProfileImgNameLarge { get; set; }
        public string? ProfileImgNameMedium { get; set; }
        public string? ProfileImgNameSmall { get; set; }
        public bool UserPro { get; set; }
        public bool VivokidUser { get; set; }
    }

    /// <summary>
    /// 单位
    /// </summary>
    public class Unit
    {
        public string? UnitId { get; set; }
        public string? UnitKey { get; set; }
        public string? Factor { get; set; }
    }

    /// <summary>
    /// 运动类型
    /// </summary>
    public class SportType
    {
        public int SportTypeId { get; set; }
        public string? SportTypeKey { get; set; }
        public int? DisplayOrder { get; set; }
    }

    // Fix for CS8767: Adjusting nullability to match the interface definition  
    public class WorkoutSegment
    {
        public int SegmentOrder { get; set; }

        // Updated SportType property to match the nullability of the interface  
        public SportType? SportType { get; set; }

        public List<WorkoutStep>? WorkoutSteps { get; set; }
    }

    /// <summary>
    /// 设备类型
    /// </summary>
    public class EquipmentType
    {
        public int EquipmentTypeId { get; set; }
        public object? EquipmentTypeKey { get; set; }
        public int DisplayOrder { get; set; }
    }

    /// <summary>
    /// 步骤类型
    /// </summary>
    public class StepType
    {
        public int StepTypeId { get; set; }
        public string? StepTypeKey { get; set; }
        public int DisplayOrder { get; set; }
    }

    /// <summary>
    /// 笔触类型
    /// </summary>
    public class StrokeType
    {
        public int StrokeTypeId { get; set; }
        public object? StrokeTypeKey { get; set; }
        public int DisplayOrder { get; set; }
    }

    /// <summary>
    /// 目标类型
    /// </summary>
    public class TargetType
    {
        public int WorkoutTargetTypeId { get; set; }
        public string? WorkoutTargetTypeKey { get; set; }
        public int DisplayOrder { get; set; }
    }

    /// <summary>
    /// 每日步数类型
    /// </summary>
    public class DailyStepsType
    {
        public string? CalendarDate { get; set; }
        public int StepGoal { get; set; }
        public int TotalDistance { get; set; }
        public int TotalSteps { get; set; }
    }

}
